﻿using DevExpress.XtraEditors;
using Lamex.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lamex.mIE.Calculate
{
    public class LGC_VAL_BOM_P79
    {
        //"E、如果包含P79
        //遍历[BOM].[COMPONENT]条件，返回
        //【P79_配件包装】=【P79_配件包装】+1"
        public static DataTable LGC_VAL_BOM_P79_VALUE(DataTable dt_BOM, string DWG_No, string Part_No, string Process_Code, string WORKTIME_LOGIC_CODE, DataTable dtfeature = null)
        {
            string errorMsg = DWG_No + Part_No + Process_Code;
            try
            {
                DataTable dtFeature_List = Common.GetTable.GetTable_Feature();
                double Feature_CheckA_VALUE = 0;
                if (dt_BOM.Rows.Count > 0)
                {
                    //for (int i = 0; i < dt_BOM.Rows.Count; i++)
                    //{
                    //    Feature_CheckA_VALUE = Feature_CheckA_VALUE +
                    //        dt_BOM.Rows[i]["SINGLE_QTY"].ToString().Length > 0 ?
                    //        Convert.ToDouble(dt_BOM.Rows[i]["SINGLE_QTY"].ToString()) : 0;
                    //}
                    //Feature_CheckA_VALUE = Feature_CheckA_VALUE + 1;
                    Feature_CheckA_VALUE = dt_BOM.Rows.Count;
                    DataRow dr = dtFeature_List.NewRow();
                    dr["DWG_NO"] = DWG_No;
                    dr["PART_NO"] = Part_No;
                    dr["PROCESS_CODE"] = Process_Code;
                    dr["FEATURE_NAME"] = "P79_配件包装";
                    dr["FEAT_VALUE"] = Feature_CheckA_VALUE;
                    dr["LABOR_VALUE"] = Calculate.LGC_TIM_VTA.LGC_TIM_VTA_VALUE(DWG_No, Part_No, "P79_配件包装", "", Feature_CheckA_VALUE);//根据特征定义表工时字段计算
                    dr["UPDATE_TIME"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                    dr["UPDATE_USER"] = Lamex.Common.Loginer.CurrentUser.AccountName;
                    dtFeature_List.Rows.Add(dr);
                }
                
                return dtFeature_List;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(errorMsg + ex.Message);
                return null;
            }
        }
    }
}
